package com.example.data.factory.web1.controller;

import com.example.data.factory.common.Dto.*;
import com.example.data.factory.common.result.R;
import com.example.data.factory.entity.entity.Dict;
import com.example.data.factory.service.service.DictService;
import io.swagger.annotations.ApiModelProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;


/**
 * <p>
 * 码表
 * </p>
 *
 * @author lhy
 * @since 2025-03-03
 */
@RestController
@RequestMapping("/dict")

public class DictController {
    private static final Logger logger = LoggerFactory.getLogger ( DictController.class );
    @Resource
    private DictService dictService;

    @ApiModelProperty("码表查询接口")
    @GetMapping("/SearchDict")
    public R<Dict> SearchDict(@ModelAttribute SearchDictDto searchDictDto) {
        return dictService.search ( searchDictDto );
    }

    @PostMapping("/InsertDict")
    public R<Dict> InsertDict(@RequestBody @Validated InsertDictDto insertDictDto, HttpServletRequest request) {
        return dictService.insert ( insertDictDto, request );
    }

    @PutMapping("/UpdateDict")
    public R<Dict> UpdateDict(@RequestBody @Validated UpdateDictDto updateDictDto) {
        return dictService.Update ( updateDictDto );
    }

    @DeleteMapping("/DeleteDict")
    public R<Dict> DeleteDict(@RequestBody DeleteDictDto deleteDictDto) {
        return dictService.Delete ( deleteDictDto );
    }

    @PutMapping("/UpdateDictStatus")
    public R<Dict> UpdateDictStatus(@RequestBody UpdateDictStatusDto updateDictStatusDto) {
        return dictService.UpdateStatus ( updateDictStatusDto );
    }

    @GetMapping("/SearchDictDetail")
    public R<Dict> SearchDictDetail(@ModelAttribute SearchDictDetaildTO searchDictDetaildTO) {
        return dictService.searchdetail ( searchDictDetaildTO );
    }

    @PutMapping("/UpdateDictStatusBatch")
    public R<Dict> UpdateDictStatusBatch(@RequestBody List<UpdateDictStatusDto> updateDictStatusDtos) {
        return dictService.updatestatusbatch ( updateDictStatusDtos );
    }

    @GetMapping("/searchs")
    public R<Dict> searchs() {
        return dictService.searchs ();
    }
}


